{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Capital BikeShare"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1、导入必要的工具包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np  # 矩阵操作\n",
    "import pandas as pd # SQL数据处理\n",
    "import matplotlib.pyplot as plt   #画图\n",
    "import seaborn as sns\n",
    "\n",
    "from sklearn.metrics import r2_score  #评价回归预测模型的性能\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2、数据探索"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2.1 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>dteday</th>\n",
       "      <th>season</th>\n",
       "      <th>yr</th>\n",
       "      <th>mnth</th>\n",
       "      <th>holiday</th>\n",
       "      <th>weekday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>weathersit</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>casual</th>\n",
       "      <th>registered</th>\n",
       "      <th>cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.344167</td>\n",
       "      <td>0.363625</td>\n",
       "      <td>0.805833</td>\n",
       "      <td>0.160446</td>\n",
       "      <td>331</td>\n",
       "      <td>654</td>\n",
       "      <td>985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2011-01-02</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.363478</td>\n",
       "      <td>0.353739</td>\n",
       "      <td>0.696087</td>\n",
       "      <td>0.248539</td>\n",
       "      <td>131</td>\n",
       "      <td>670</td>\n",
       "      <td>801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2011-01-03</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.196364</td>\n",
       "      <td>0.189405</td>\n",
       "      <td>0.437273</td>\n",
       "      <td>0.248309</td>\n",
       "      <td>120</td>\n",
       "      <td>1229</td>\n",
       "      <td>1349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>2011-01-04</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.212122</td>\n",
       "      <td>0.590435</td>\n",
       "      <td>0.160296</td>\n",
       "      <td>108</td>\n",
       "      <td>1454</td>\n",
       "      <td>1562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2011-01-05</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.226957</td>\n",
       "      <td>0.229270</td>\n",
       "      <td>0.436957</td>\n",
       "      <td>0.186900</td>\n",
       "      <td>82</td>\n",
       "      <td>1518</td>\n",
       "      <td>1600</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   instant      dteday  season  yr  mnth  holiday  weekday  workingday  \\\n",
       "0        1  2011-01-01       1   0     1        0        6           0   \n",
       "1        2  2011-01-02       1   0     1        0        0           0   \n",
       "2        3  2011-01-03       1   0     1        0        1           1   \n",
       "3        4  2011-01-04       1   0     1        0        2           1   \n",
       "4        5  2011-01-05       1   0     1        0        3           1   \n",
       "\n",
       "   weathersit      temp     atemp       hum  windspeed  casual  registered  \\\n",
       "0           2  0.344167  0.363625  0.805833   0.160446     331         654   \n",
       "1           2  0.363478  0.353739  0.696087   0.248539     131         670   \n",
       "2           1  0.196364  0.189405  0.437273   0.248309     120        1229   \n",
       "3           1  0.200000  0.212122  0.590435   0.160296     108        1454   \n",
       "4           1  0.226957  0.229270  0.436957   0.186900      82        1518   \n",
       "\n",
       "    cnt  \n",
       "0   985  \n",
       "1   801  \n",
       "2  1349  \n",
       "3  1562  \n",
       "4  1600  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv(\"day.csv\")\n",
    "data_copy = pd.read_csv(\"day.csv\")\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  2.2 数据基本信息\n",
    "样本数目、特征维数\n",
    "每个特征的类型、空值样本的数目、数据类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "del data['dteday']\n",
    "del data['instant']\n",
    "del data['atemp']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['season', 'mnth', 'holiday', 'weekday', 'workingday', 'weathersit',\n",
       "       'temp', 'hum', 'windspeed'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X = data.drop(['yr','casual','registered','cnt'], axis = 1)\n",
    "\n",
    "#用于后续显示权重系数对应的特征\n",
    "columns = X.columns\n",
    "columns"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2.3 数据准备"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/lihuixiang/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py:444: DataConversionWarning: Data with input dtype int64 was converted to float64 by the scale function.\n",
      "  warnings.warn(msg, DataConversionWarning)\n"
     ]
    }
   ],
   "source": [
    "# 按年份分离train & test data\n",
    "data_train=data[data.yr<1]\n",
    "data_test=data[data.yr>0]\n",
    "\n",
    "# y 值输入 + 两年的数值范围不易，做均值补偿\n",
    "# from sklearn.preprocessing import Normalizer\n",
    "y_train = data_train['casual'].values\n",
    "y_test = data_test['casual'].values\n",
    "# y_train\n",
    "# y_train = Normalizer().fit_transform(y_train.reshape(-1,1)) \n",
    "# y_test = Normalizer().transform(y_test.reshape(-1,1))\n",
    "# from sklearn.preprocessing import Normalizer\n",
    "# y_train=Normalizer().fit_transform(y_train.reshape(-1,1))\n",
    "# y_test=Normalizer().fit_transform(y_test.reshape(-1,1))\n",
    "\n",
    "from sklearn import preprocessing\n",
    "y_train = preprocessing.scale(y_train.reshape(-1, 1))\n",
    "y_test = preprocessing.scale(y_test.reshape(-1, 1))\n",
    "\n",
    "# define value features\n",
    "columns_num = ['mnth','holiday','weekday','workingday','season','weathersit','cnt','yr','registered','casual']\n",
    "columns_onehot=['cnt','yr','registered','casual','temp','hum','windspeed']\n",
    "# seperate x into to catagories, one with value features, another contains classfied features\n",
    "X_train_onehot=data_train.drop(columns_onehot,axis=1)\n",
    "X_train_num=data_train.drop(columns_num,axis=1)\n",
    "X_test_onehot=data_test.drop(columns_onehot,axis=1)\n",
    "X_test_num=data_test.drop(columns_num,axis=1)\n",
    "\n",
    "# onehotencoder the x which contains classified features\n",
    "from sklearn.preprocessing import OneHotEncoder\n",
    "X_train_onehot=OneHotEncoder(sparse=False).fit_transform(X_train_onehot)\n",
    "X_test_onehot=OneHotEncoder(sparse=False).fit_transform(X_test_onehot)\n",
    "# X_train_onehot=OneHotEncoder().fit_transform(X_train_onehot)\n",
    "# X_test_onehot=OneHotEncoder().fit_transform(X_test_onehot)\n",
    "\n",
    "# X_train_onehot=pd.DataFrame(OneHotEncoder().fit_transform(X_train_onehot).toarray())\n",
    "# X_test_onehot=pd.DataFrame(OneHotEncoder().fit_transform(X_test_onehot).toarray())\n",
    "\n",
    "\n",
    "#Normalize the x which contains value features\n",
    "from sklearn.preprocessing import Normalizer\n",
    "X_train_num=Normalizer().fit_transform(X_train_num)\n",
    "X_test_num=Normalizer().fit_transform(X_test_num)\n",
    "\n",
    "# from sklearn import preprocessing\n",
    "# enc = preprocessing.OneHotEncoder()\n",
    "# #onehot = pd.DataFrame(enc.fit_transform(data[['season','mnth','weekday','weathersit']]).toarray())\n",
    "# data22=data[['season','mnth','weekday','weathersit']]\n",
    "# onehot = pd.DataFrame(enc.fit_transform(X_train_onehot).toarray())\n",
    "\n",
    "# onehot\n",
    "\n",
    "# # data_temp = data.drop(['season','mnth','weekday','weathersit'], axis = 1)\n",
    "# data_new = pd.concat([X_train_num, X_train_onehot],axis=1 )  #与独热编码的数据合并\n",
    "\n",
    "# data22=data[['season','mnth','weekday','weathersit']]\n",
    "# data11=data_train.drop(columns_onehot,axis=1)\n",
    "#data22"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(365, 3)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# verify shape of two Xs\n",
    "X_train_num.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.,  0.,  0., ...,  0.,  1.,  0.],\n",
       "       [ 1.,  0.,  0., ...,  0.,  1.,  0.],\n",
       "       [ 1.,  0.,  0., ...,  1.,  0.,  0.],\n",
       "       ..., \n",
       "       [ 1.,  0.,  0., ...,  1.,  0.,  0.],\n",
       "       [ 1.,  0.,  0., ...,  1.,  0.,  0.],\n",
       "       [ 1.,  0.,  0., ...,  1.,  0.,  0.]])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# verify shape of two Xs\n",
    "X_train_onehot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.        ,  0.        ,  0.        , ...,  0.38634844,\n",
       "         0.90459666,  0.18011042],\n",
       "       [ 1.        ,  0.        ,  0.        , ...,  0.44129317,\n",
       "         0.84510875,  0.30174746],\n",
       "       [ 1.        ,  0.        ,  0.        , ...,  0.36374692,\n",
       "         0.8100095 ,  0.45997043],\n",
       "       ..., \n",
       "       [ 1.        ,  0.        ,  0.        , ...,  0.38993074,\n",
       "         0.901553  ,  0.18749989],\n",
       "       [ 1.        ,  0.        ,  0.        , ...,  0.43198526,\n",
       "         0.8824507 ,  0.18619746],\n",
       "       [ 1.        ,  0.        ,  0.        , ...,  0.53116203,\n",
       "         0.79782221,  0.28521328]])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# merge two Xs\n",
    "X_train=np.hstack((X_train_onehot,X_train_num))\n",
    "X_test=np.hstack((X_test_onehot,X_test_num))\n",
    "X_train\n",
    "\n",
    "\n",
    "# from scipy.sparse import hstack \n",
    "# X_train=hstack((X_train_num,X_train_onehot))\n",
    "# X_test=hstack((X_test_num,X_test_onehot))\n",
    "\n",
    "# X_train=pd.concat([X_train_onehot,X_train_num],axis=1)\n",
    "# X_train"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3、确定模型类型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.1 尝试缺省参数的线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# 线性回归\n",
    "#class sklearn.linear_model.LinearRegression(fit_intercept=True, normalize=False, copy_X=True, n_jobs=1)\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "# 训练模型参数\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "y_test_pred_lr = lr.predict(X_test)\n",
    "y_train_pred_lr = lr.predict(X_train)\n",
    "\n",
    "# columns=X_train.columns\n",
    "\n",
    "# # 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "# fs = pd.DataFrame({\"columns\":list(columns), \"coef\":list((lr.coef_.T))})\n",
    "# fs.sort_values(by=['coef'],ascending=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 3.1.1 模型评价"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LinearRegression on test is 0.700404873272\n",
      "The r2 score of LinearRegression on train is 0.749149810312\n"
     ]
    }
   ],
   "source": [
    "# 使用r2_score评价模型在测试集和训练集上的性能，并输出评估结果\n",
    "#测试集\n",
    "print ('The r2 score of LinearRegression on test is', r2_score(y_test, y_test_pred_lr))\n",
    "#训练集\n",
    "print ('The r2 score of LinearRegression on train is', r2_score(y_train, y_train_pred_lr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAekAAAFsCAYAAADos0H8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGnRJREFUeJzt3X+Y1nWd7/HnW5jEdRRCQRE6gaXmT8BGgmMaRaW7mLh7\nKuv4Ay9Ru6z2stp+Wad1cutsXXrs5MntWrYfalqibi6eujqrh4UlPa7GGJmGBWuygQQjpYBlMvA+\nf9xfaIAZGGbmnvk49/NxXVz3/f3e3x/v+3sP85rP5/uZz0RmIkmSynPAYBcgSZK6ZkhLklQoQ1qS\npEIZ0pIkFcqQliSpUIa0JEmFMqTV8CLiiYiYOdh1DKaI+POI+FVEbImIqQN43i0RcXQ3r10SEQ/0\n03mejoi39sexpIFkSGtI6+qb8+7f/DPzxMxcso/jTIyIjIjhdSp1sF0PfDAzmzPzx7u/WL33F6pQ\nXRsRN0TEsL6etDrfU309jjRUGdJSAQoI/1cDT+xjm8mZ2Qy8CTgfuLTuVUkNzpBWw+vc2o6IaRGx\nLCI2RcT6iLih2mxp9fhc1ZqcEREHRMR/i4jVEbEhIm6NiJGdjntx9drGiPjMbudpjYi7I+K2iNgE\nXFKd+6GIeC4i1kXEVyLiFZ2OlxHx/ohYGRGbI+JvIuI11T6bIuLOztvv9h67rDUiDoyILcAw4CcR\n8e/7ul6ZuQp4EJjS6fgjI+LrVd1rI+JzO1raEfHaiPjXiHg+Ip6NiAW7vafXVs8Pi4h7q/fyCPCa\nTtvt0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y+tprr+WNb3wjd911V49q6Sm7uyVJu9i2bRuLFi1i3rx5ANx3332sXLmSRx55hMzk\n3HPPZenSpbS3t3PUUUfx/e9/H4Dnn39+l+OsW7eOa665hra2NkaOHMmb3/xmpk6dutdzjxgxgnvu\nuYdDDz2UZ599lunTp3PuuefuMgjr29/+NmeddRaf/vSn2bZtG7/73e969T6ffPJJFi9ezObNmznu\nuOO48sorWbVqFQsWLODBBx+kqamJ97///dx+++1cfPHFfP7zn2f06NFs27aNWbNm8dhjj3HKKafs\nrPuBBx7oVR17Y0hLkgD4/e9/z5QpU3j66ad5/etfz9ve9jagFtL33XffzoDdsmULK1eu5IwzzuCj\nH/0on/jEJzjnnHM444wzdjneww8/zMyZMxkzpvYHn84//3x+8Ytf7LWGzORTn/oUS5cu5YADDmDt\n2rWsX7+eI488cuc2p512Gpdeeilbt27lvPPOY8qUKb16v7Nnz+bAAw/kwAMPZOzYsaxfv55FixbR\n1tbGaaedtvOajB07FoA777yT+fPn09HRwbp16/jZz362M6TPP//8XtWwL3Z3S5KAP96TXr16NS+9\n9NLOe9KZydVXX83y5ctZvnw5q1atYt68eRx77LG0tbVx8sknc/XVV3Pttdfucczufg1p+PDhbN++\nfefxX3rpJQBuv/122tvbaWtrY/ny5RxxxBF7/K7xmWeeydKlSxk/fjwXXXQRt956a6/e74EHHrjz\n+bBhw+jo6CAzmTt37s73+vOf/5zW1lZ++ctfcv3117No0SIee+wxZs+evUtdBx98cK9q2Bdb0hpy\nejoqtr9Hz0pDxciRI7nxxhuZM2cOV155JWeddRaf+cxnuOCCC2hubmbt2rU0NTXR0dHB6NGjufDC\nC2lububmm2/e5ThveMMbuOqqq9i4cSOHHnood911F5MnTwZq93Hb2tp497vfzcKFC9m6dStQ6zIf\nO3YsTU1NLF68mNWr9/yrjqtXr2b8+PFcfvnlvPDCCzz66KNcfPHF/fLeZ82axZw5c/jwhz/M2LFj\n+c1vfsPmzZvZtGkTBx98MCNHjmT9+vX84Ac/YObMmf1yzr0xpCW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SGkI2IYcBPwp8AJwHsj4oT+KkySpEbXl5b0NGBVZj6V\nmS8BdwBz+qcsSZIUmdm7HSPeCZydmZdVyxcBb8jMD+623RXAFdXiccDPe1/ukHQ48OxgF9FAvN4D\nx2s9sLzeA6ev1/rVmTmmJxv25Vewoot1eyR+Zs4H5vfhPENaRCzLzJbBrqNReL0Hjtd6YHm9B85A\nXuu+dHevAV7VaXkC8EzfypEkSTv0JaR/BBwTEZMi4hXAe4B7+6csSZLU6+7uzOyIiA8C/wwMA76R\nmU/0W2WNw1sBA8vrPXC81gPL6z1wBuxa93rgmCRJqi9nHJMkqVCGtCRJhTKkCxAR74qIJyJie0T4\nKxR14BS2AycivhERGyLi8cGuZaiLiFdFxOKIWFF9D7lqsGsayiJiREQ8EhE/qa73Z+t9TkO6DI8D\nfwEsHexChiKnsB1wNwNnD3YRDaID+KvMPB6YDnzAr+26+gPwlsycDEwBzo6I6fU8oSFdgMxckZnO\nxFY/TmE7gDJzKfCbwa6jEWTmusx8tHq+GVgBjB/cqoaurNlSLTZV/+o6+tqQViMYD/yq0/Ia/Eam\nISYiJgJTgYcHt5KhLSKGRcRyYANwf2bW9Xr3ZVpQ7YeI+L/AkV289OnMXDjQ9TSYHk1hK71cRUQz\n8I/AhzJz02DXM5Rl5jZgSkSMAu6JiJMys27jLwzpAZKZbx3sGhqYU9hqyIqIJmoBfXtmfnew62kU\nmflcRCyhNv6ibiFtd7cagVPYakiKiAC+DqzIzBsGu56hLiLGVC1oIuIg4K3Ak/U8pyFdgIj484hY\nA8wAvh8R/zzYNQ0lmdkB7JjCdgVwp1PY1k9EfAd4CDguItZExLzBrmkIOx24CHhLRCyv/v3ZYBc1\nhI0DFkfEY9R++L8/M79XzxM6LagkSYWyJS1JUqEMaUmSCmVIS5JUKENakqRCGdKSJBXKkJYkqVCG\ntCRJhfr/NOfr+ia3JPMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10fed2a58>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#在训练集上观察预测残差的分布，看是否符合模型假设：噪声为0均值的高斯噪声\n",
    "f, ax = plt.subplots(figsize=(7, 5)) \n",
    "f.tight_layout() \n",
    "ax.hist(y_train - y_train_pred_lr,bins=40, label='Residuals Linear', color='b', alpha=.5); \n",
    "ax.set_title(\"Histogram of Residuals\") \n",
    "ax.legend(loc='best');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "残差分布和高斯分布比较匹配，但还是左skew，可能是由于数据集中有16个数据的y值为最大值，有噪声（预测残差超过2.5）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VPX18PHPyTAhE7ZEDSqRzQ1rqyU1AgVcQEQpilS0\nLli3PuWx6vNTa9nccGmVgvZn+zzWFqvVCq1UQVqgFnGjD5UoYGgtrgiCBCVhiSwZyHZ+f8wkJmFm\ncie5d+4kOe/XK69mMpN7z1Tm5Luer6gqxhjjhQy/AzDGtF+WYIwxnrEEY4zxjCUYY4xnLMEYYzxj\nCcYY4xlLMMYYz1iCMcZ4xhKMMcYznfwOIBlHHHGE9uvXz+8wjOnw1q5du0NV85p7XZtKMP369WPN\nmjV+h2FMhycim528zrpIxhjPWIIxxnjGtwQjIlki8raI/EtE1ovIfX7FYozxhp9jMAeBkaq6T0SC\nwEoReUlVi3yMyRjjIt9aMBqxL/owGP2y4jSm3ausrOTjjz/2O4yU8HUMRkQCIrIOKAWWq+pbMV4z\nSUTWiMiasrKy1AdpjMsqKyu55ZZb2Lt3r9+heM7XBKOqNao6EDgGGCQi34jxmjmqWqiqhXl5zU67\nG5O2Nm3axP79++natSsLFy6kW7dufofkubSYRVLVcuAN4HyfQzHG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ayvfCGH9ZF8l4QkSOF5H/RBccvgP0FpHyBs9fLiK/i35/pIgsFJE1IvK2iAzxK27j\nLkswxksnA0+qagGRbQbx/AqYFT2z53v4UFbAeMPGYIyXPlHV1Q5eNwoYEOlJAZArIiFVDXsXmkkF\nSzDGS/sbfF9L49IPWQ2+F2xAuF2yLpJJiegA724ROUFEMoDvNnj6FeCmugciMjDV8RlvWIIxqTQV\n+DuRae2tDX5+EzAsWjD9PeCHfgRn3GfT1MYYz1gLxhjjGUswxhjPWIIxxnjGEowxxjOWYIwxnrEE\nY4zxjCUYY4xn/gcUFAYEN8mCPgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a19f567f0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#还可以观察预测值与真值的散点图\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_train, y_train_pred_lr)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')   #数据已经标准化，3倍标准差即可\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True ')\n",
    "plt.ylabel('Predicted ')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在y的真值大的部分预测效果不好"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/lihuixiang/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py:547: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([-0.08973455, -0.02280137,  0.08686748, -0.03581062, -0.49936736,\n",
       "       -0.43733371, -0.11044915,  0.19005618,  0.43444995,  0.2349678 ,\n",
       "        0.22678233,  0.02148798,  0.23574638,  0.25996385, -0.14266627,\n",
       "       -0.47511706, -0.04287774, -0.01860132,  0.19884541, -0.01770257,\n",
       "       -0.13064228, -0.17821059, -0.17611543,  0.01621687,  0.22612953,\n",
       "        0.40637362, -0.46785268,  0.23397988,  0.05855168, -0.35401062,\n",
       "        1.44385528, -0.49753787, -1.06229253])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性模型，随机梯度下降优化模型参数\n",
    "# 随机梯度下降一般在大数据集上应用，其实本项目不适合用\n",
    "from sklearn.linear_model import SGDRegressor\n",
    "\n",
    "# 使用默认配置初始化线\n",
    "sgdr = SGDRegressor(max_iter=1000)\n",
    "\n",
    "# 训练：参数估计\n",
    "sgdr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "#sgdr_y_predict = sgdr.predict(X_test)\n",
    "\n",
    "sgdr.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of default measurement of SGDRegressor on test is 0.714320323114\n",
      "The value of default measurement of SGDRegressor on train is 0.75482451488\n"
     ]
    }
   ],
   "source": [
    "# 使用SGDRegressor模型自带的评估模块(评价准则为r2_score)，并输出评估结果\n",
    "print ('The value of default measurement of SGDRegressor on test is', sgdr.score(X_test, y_test))\n",
    "print ('The value of default measurement of SGDRegressor on train is', sgdr.score(X_train, y_train))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#这里由于样本数不多，SGDRegressor可能不如LinearRegression。 sklearn建议样本数超过10万采用SGDRegressor"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.2 正则化的线性回归（L2正则 --> 岭回归）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of RidgeCV on test is 0.719987778174\n",
      "The r2 score of RidgeCV on train is 0.75929497961\n"
     ]
    }
   ],
   "source": [
    "#岭回归／L2正则\n",
    "#class sklearn.linear_model.RidgeCV(alphas=(0.1, 1.0, 10.0), fit_intercept=True, \n",
    "#                                  normalize=False, scoring=None, cv=None, gcv_mode=None, \n",
    "#                                  store_cv_values=False)\n",
    "from sklearn.linear_model import  RidgeCV\n",
    "\n",
    "#设置超参数（正则参数）范围\n",
    "alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "#n_alphas = 20\n",
    "#alphas = np.logspace(-5,2,n_alphas)\n",
    "\n",
    "#生成一个RidgeCV实例\n",
    "ridge = RidgeCV(alphas=alphas, store_cv_values=True)  \n",
    "\n",
    "#模型训练\n",
    "ridge.fit(X_train, y_train)    \n",
    "\n",
    "#预测\n",
    "y_test_pred_ridge = ridge.predict(X_test)\n",
    "y_train_pred_ridge = ridge.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print ('The r2 score of RidgeCV on test is', r2_score(y_test, y_test_pred_ridge))\n",
    "print ('The r2 score of RidgeCV on train is', r2_score(y_train, y_train_pred_ridge))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEKCAYAAADjDHn2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xt4FfW97/H3l5BwEwUkoIRLQPECooIRb6DWK9ZWsNpW\n7a62W6U+W07tbe/ap922td37nNpz7HP2Kbu7iLbV1k29FKVKi9ZqASuWYKAYkQoBSsItCALhltv3\n/DGzcBEmWSuQWZfk83qePFkz85s13yzC+mZm1nzG3B0REZG2dMt2ASIikvvULEREJCU1CxERSUnN\nQkREUlKz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Al5vZTt7gbFmtix8nk+nqOs/gWfN7JMEqbB7k5Z9JKxBJFZKnRVJg5kd\n58Gd0U4k2Nu4JGwkvQjewC8Jz3Wk81x17n5cB9W1EJjq7js74vlEWqM9C5H0vGBm/YAi4HvuvgXA\n3feb2bcJ7nP890wWFB4qe1iNQjJBexYiIpKSTnCLiEhKahYiIpKSmoWIiKSkZiEiIimpWYiISEpq\nFiIiktL/Bxzg/pqNa6rmAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10fc8e358>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.01\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(9,)"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_mean = np.mean(ridge.cv_values_, axis = 0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas),1)) \n",
    "\n",
    "#这是为了标出最佳参数的位置，不是必须\n",
    "#plt.plot(np.log10(ridge.alpha_)*np.ones(3), [0.28, 0.29, 0.30])\n",
    "\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print ('alpha is:', ridge.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "# fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T))})\n",
    "# fs.sort_values(by=['coef_lr'],ascending=False)\n",
    "\n",
    "columns.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3.3 正则化的线性回归（L1正则 --> Lasso）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LassoCV on test is 0.720817568173\n",
      "The r2 score of LassoCV on train is 0.75837926545\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/lihuixiang/anaconda3/lib/python3.6/site-packages/sklearn/linear_model/coordinate_descent.py:1094: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    }
   ],
   "source": [
    "#### Lasso／L1正则\n",
    "# class sklearn.linear_model.LassoCV(eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, \n",
    "#                                    normalize=False, precompute=’auto’, max_iter=1000, \n",
    "#                                    tol=0.0001, copy_X=True, cv=None, verbose=False, n_jobs=1,\n",
    "#                                    positive=False, random_state=None, selection=’cyclic’)\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "#设置超参数搜索范围\n",
    "#alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "\n",
    "#生成一个LassoCV实例\n",
    "#lasso = LassoCV(alphas=alphas)  \n",
    "lasso = LassoCV()  \n",
    "\n",
    "#训练（内含CV）\n",
    "lasso.fit(X_train, y_train)  \n",
    "\n",
    "#测试\n",
    "y_test_pred_lasso = lasso.predict(X_test)\n",
    "y_train_pred_lasso = lasso.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print ('The r2 score of LassoCV on test is', r2_score(y_test, y_test_pred_lasso))\n",
    "print ('The r2 score of LassoCV on train is', r2_score(y_train, y_train_pred_lasso))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAEKCAYAAADn+anLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd81fW9x/HXJ3tAAhmMkEDYoCw1IIhWcGutVlvr6FCr\nxWod1XqvWlut7W2vtbf1tr1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3oH7/MzE5oM/4VfwaRLqWSkJ7oQmASMBE4DfiN/3g3FwK5wHjgamBam+dM\nB5a2uX2ncy4PmACcbGYT2nmfZGCZc+5Y4AP+/RhaMc65KcAP29xfDJzuH38x8Ic245cAJ3V8UkWO\nTI85wJ9IGycCzzrnWoA9ZvYBMNl//4vOOR+w28zea/OcgUBJm9vf8B8CO8b/2FG0HgqlLR/wvP/6\n08CcNo/tv76U1mICiAX+z8wmAS3AqDbji2k9XIRIl1JJSE/U3uGfD3Y/QB2QAGBmQ4FbgcnOub1m\n9sT+xw6h7TFwGvw/W/jX7+HNtB5DaCKtc/n1bcYn+DOIdCktbpKeaD5wsZlF+9cTfAlYDHwEfM2/\nbqI//3449XXACP/1FKAGqPCPOzvA+0QB+9dpXOZ//YNJBXb552S+TeupM/cbReQeSVUimOYkpCd6\nmdb1DSto/ev+P51zu83sJeBUWr+MNwKLgAr/c96gtTTecc6tMLPltB7htAD4OMD71ABHm9lS/+tc\nfIhcDwAvmdlFwHv+5+83059BpEvpKLAibZhZL+dctZml0zp3Md1fIIm0fnFP96/LCOa1qp1zvTop\n13zgfNd6TnKRLqM5CZF/97qZ9QHigF8453YDOOfqzOxuWs9vvL0rA/kXif1OBSFe0JyEiIgEpBXX\nIiISkEpCREQCUkmIiEhAKgkREQlIJSEiIgGpJEREJKD/B7FQXMgb6bKDAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a1a044048>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.000823590605881\n"
     ]
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "           \n",
    "print ('alpha is:', lasso.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "# fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T)), \"coef_lasso\":list((lasso.coef_.T))})\n",
    "# fs.sort_values(by=['coef_lr'],ascending=False)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAEKCAYAAADn+anLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd81fW9x/HXJ3tAAhmMkEDYoCw1IIhWcGutVlvr6FCr\nxWod1XqvWlut7W2vtbf1tr1Vq9ZVcVa0DqpiHTgYMmSvEFYIkAXZ+3zvHznYFHPgBHLyOyd5Px+P\n88gZ33PO+8ch553fNuccIiIi7YnyOoCIiIQvlYSIiASkkhARkYBUEiIiEpBKQkREAlJJiIhIQCoJ\nEREJSCUhIiIBqSRERCSgGK8DdFRGRobLzc31OoaISERZunRpqXMus6PPi7iSyM3NZcmSJV7HEBGJ\nKGa27XCep8VNIiISkEpCREQCUkmIiEhAKgkREQlIJSEiIgGpJEREJCCVhIiIBKSSEBEJc00tPh54\nP5/l2/d2+XurJEREwtjSbeWc+4ePuO/NDby1Zk+Xv3/E7XEtItITNLf4uOe1tfx14TYG9Unk0e/k\ncdpR/bs8h0pCRCTMOOe4Y84qXlxayFUnDuWW00eRHO/N17VKQkQkzPz6zQ28uLSQm04dyc2nj/I0\ni9ZJiIiEkUc/LOChDzbzzeMH88PTRnodRyUhIhIuFm8p57/eWMc54wfw8/PHYWZeR1JJiIiEg4bm\nFu6Ys5Lsvon8z0UTiY7yviBA6yRERMLCg+9vZnNJDU9cOZmkuPD5atachIiIx/KLq3ngvc2cNzGL\nGaP7eR3n36gkREQ85PM5fvzyKh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Z9QHigF8453YDOOfqzOxuWs9vvL0rA/kXif1OBSFe0JyEiIgEpBXX\nIiISkEpCREQCUkmIiEhAKgkREQlIJSEiIgGpJEREJKD/B7FQXMgb6bKDAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a1ac61be0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.000823590605881\n"
     ]
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
